﻿using DJ.Dialog;
using DJ.ZEF.ThirdParty;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DJ.Clients
{
    /// <summary>
    /// BoxTypeView.xaml 的交互逻辑
    /// </summary>
    public partial class BoxTypeView : Window
    {
        public BoxTypeView()
        {
            InitializeComponent();
            ComWindow.Start(this, Label1);
            VoiceHelper.GetInstance().Start("请选择箱格大小");
        }

        //确定
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(type))
            {
                MessageDialog.ShowDialog("请选择箱格大小");
                return;
            }
            DialogResult = true;
        }

        public string type;
        private void Button_MouseDown(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            if (btn.Tag.ToString() =="0")
            {
                btn.Tag = "1";
                string filepath = null;
                switch (btn.Content.ToString())
                {
                    case "大":
                        filepath = "pack://application:,,,/ClientImage/box_L1.png";
                        btn2.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ClientImage/box_M.png")));
                        btn2.Tag = "0";
                        btn3.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ClientImage/box_S.png")));
                        btn3.Tag = "0";
                        break;
                    case "中":
                        filepath = "pack://application:,,,/ClientImage/box_M1.png";
                        btn1.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ClientImage/box_L.png")));
                        btn1.Tag = "0";
                        btn3.Tag = "0";
                        btn3.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ClientImage/box_S.png")));
                        break;
                    case "小":
                        filepath = "pack://application:,,,/ClientImage/box_S1.png";
                        btn1.Tag = "0";
                        btn2.Tag = "0";
                        btn2.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ClientImage/box_M.png")));
                        btn1.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ClientImage/box_L.png")));
                        break;
                }
                type = btn.Content.ToString();
                btn.Background = new ImageBrush(new BitmapImage(new Uri(filepath)));
            }
            else
            {
                btn.Tag = "0";
                string filepath = null;
                switch (btn.Content.ToString())
                {
                    case "大":
                        filepath = "pack://application:,,,/ClientImage/box_L.png";
                        break;
                    case "中":
                        filepath = "pack://application:,,,/ClientImage/box_M.png";
                        break;
                    case "小":
                        filepath = "pack://application:,,,/ClientImage/box_S.png";
                        break;
                }
                type = null;
                btn.Background = new ImageBrush(new BitmapImage(new Uri(filepath)));
            }
        }

        private void btn_return(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
